﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PmSadis.CsExtantions;

namespace PmSadis.Providers
{
    /// <summary>
    /// Итемы перечислений
    /// </summary>
    public static class AppEnums
    {
        /// <summary>
        /// Список типов элементов
        /// </summary>
        /// <returns></returns>
        public static IQueryable GetAllElementTypes()
        {
            var result = new Dictionary<object, string>();
            var values = Enum.GetValues(typeof(PmSadis.Models.Enums.ElementType));
            foreach (PmSadis.Models.Enums.ElementType value in values)
            {
                result.Add((int)value, value.GetDescription());
            }
            return result.ToList().Select(x => new
            {
                Value = x.Key,
                Text = x.Value
            })
            .AsQueryable();
        }

        /// <summary>
        /// Список типов объектов
        /// </summary>
        /// <returns></returns>
        public static IQueryable GetAllObjectTypes()
        {
            var result = new Dictionary<object, string>();
            var values = Enum.GetValues(typeof(PmSadis.Models.Enums.ObjectType));
            foreach (PmSadis.Models.Enums.ObjectType value in values)
            {
                result.Add((int)value, value.GetDescription());
            }
            return result.ToList().Select(x => new
            {
                Value = x.Key,
                Text = x.Value
            })
            .AsQueryable();
        }

        /// <summary>
        /// Список видов работ
        /// </summary>
        /// <returns></returns>
        public static IQueryable GetAllWorkKinds()
        {
            var result = new Dictionary<object, string>();
            var values = Enum.GetValues(typeof(PmSadis.Models.Enums.WorkKind));
            foreach (PmSadis.Models.Enums.WorkKind value in values)
            {
                result.Add((int)value, value.GetDescription());
            }
            return result.ToList().Select(x => new
            {
                Value = x.Key,
                Text = x.Value
            })
            .AsQueryable();
        }
    }
}
